using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default2 : System.Web.UI.Page
{
    MembershipUser User;
    object UserGUID;


    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            User = Membership.GetUser(HttpContext.Current.User.Identity.Name);
            UserGUID = User.ProviderUserKey;
             
            //testy
            

            UserGuidLabel.Text = UserGUID.ToString();
            UsernameLabel.Text = User.UserName;
        }
    }
    protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
    {
        DataSourceSelectArguments dssa = new DataSourceSelectArguments();
        DataView dv = (DataView)SqlDataSource1.Select(dssa);
        DataTable dt = dv.ToTable();
        DataRow dr = dt.Rows[0];

        SqlDataSource1.UpdateParameters.Add("rola", TypeCode.Int32, dr["rola"].ToString());
        SqlDataSource1.UpdateParameters.Add("user_guid", TypeCode.String, dr["user_guid"].ToString());
        SqlDataSource1.UpdateParameters.Add("ulubiona_druzyna1", TypeCode.Int32, dr["ulubiona_druzyna1"].ToString());
        SqlDataSource1.UpdateParameters.Add("ulubiona_druzyna2", TypeCode.Int32, dr["ulubiona_druzyna2"].ToString());
        SqlDataSource1.UpdateParameters.Add("ulubiona_druzyna3", TypeCode.Int32, dr["ulubiona_druzyna3"].ToString());
    }
    protected void DV1DataUrodzeniaTextBox_PreRender(object sender, EventArgs e)
    {
        TextBox tb = (TextBox)DetailsView1.FindControl("DV1DataUrodzeniaTextBox");

        if (tb.Text.Length != 0)
            tb.Text = tb.Text.Remove(10);
    }
    protected void Label4_PreRender(object sender, EventArgs e)
    {
        Label lb = (Label)DetailsView1.FindControl("Label4");

        if (lb.Text.Length != 0)
            lb.Text = lb.Text.Remove(10);
    }
}